package com.surprise.db.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import com.surprise.db.entity.SurpriseProduct;

/**
 * SurpriseProductRepository.java
 * @author xuling
 * @since 2017年9月29日
**/
public interface SurpriseProductRepository extends JpaRepository<SurpriseProduct, Long> {

	@Query("select o from surprise_product o where o.surpriseShopId = ?1") 
	public List<SurpriseProduct> findAllBySurpriseShopId(long surpriseShopId);
	
	@Modifying
	@Transactional
	@Query(value="update surprise_product o set o.qrcode=:qrcode, o.updatetime = now() where o.id = :id")
	public int updateQrcodeById(@Param("qrcode")String qrcode, @Param("id")long id);
}
